Sketch in Yahoo geocode reader.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 12 Dec 2005 15:43:00 +0000 (15:43 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 12 Dec 2005 15:43:00 +0000 (15:43 +0000)
gpsbabel/Makefile
gpsbabel/vecs.c
gpsbabel/yahoo.c [new file with mode: 0644]

index a39b8799788274d1fe208b637ac4d54d119a144e..2adebd792e1e3f73792248fca7e646fdbe7aead5 100644 (file)
@@ -44,7 +44,8 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \
        igc.o brauniger_iq.o shape.o hiketech.o glogbook.o coastexp.o \
        vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \
        tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o coto.o \
-       ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o
+       ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o \
+       yahoo.o
 
 FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o \
        reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \
index 679b37803bd43a1fd52c3b105fc8c883cca7fa0e..322f2de82bdd105cadc717dd6e02515bec159700 100644 (file)
@@ -94,6 +94,7 @@ extern ff_vecs_t cst_vecs;
 extern ff_vecs_t nmn4_vecs;
 extern ff_vecs_t magpdb_vecs;
 extern ff_vecs_t compegps_vecs;
+extern ff_vecs_t yahoo_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -482,6 +483,12 @@ vecs_t vec_list[] = {
                "CompeGPS data files (.wpt/.trk/.rte)",
                NULL
        },
+       {
+               &yahoo_vecs,
+               "yahoo",
+               "Yahoo Geocode API data",
+               NULL
+       },
        {
                NULL,
                NULL,
diff --git a/gpsbabel/yahoo.c b/gpsbabel/yahoo.c
new file mode 100644 (file)
index 0000000..bd808f8
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+    Read Yahoo Geocoded files.
+
+    Copyright (C) 2005 Robert Lipe, robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#include "defs.h"
+#include "xmlgeneric.h"
+
+static FILE *ifd;
+static waypoint *wpt_tmp;
+
+#define MYNAME "yahoo"
+
+static
+arglist_t yahoo_args[] = {
+       {0, 0, 0, 0, 0}
+};
+
+static xg_callback     wpt_s, wpt_lat, wpt_lon, wpt_e;
+
+static xg_tag_mapping gl_map[] = {
+ { wpt_s,      cb_start, "/ResultSet/Result" },
+ { wpt_lat,    cb_cdata, "/ResultSet/Result/Latitude" },
+ { wpt_lon,    cb_cdata, "/ResultSet/Result/Longitude" },
+ { wpt_e,      cb_end,   "/ResultSet/Result" },
+ { NULL,       0,         NULL}
+};
+
+static void
+yahoo_rd_init(const char *fname)
+{
+       xml_init(fname, gl_map, NULL);
+}
+
+static void
+yahoo_read(void)
+{
+       xml_read();
+}
+
+static void
+yahoo_rd_deinit(void)
+{
+       xml_deinit();
+}
+
+static void
+yahoo_wr_init(const char *fname)
+{
+       fatal("Writing file of type %s is not supported\n", MYNAME);
+}
+
+void   wpt_s(const char *args, const char **unused)
+{
+       wpt_tmp = waypt_new();
+}
+
+void   wpt_e(const char *args, const char **unused)
+{
+       waypt_add(wpt_tmp);
+       wpt_tmp = NULL;
+}
+
+void   wpt_lat(const char *args, const char **unused)
+{
+       wpt_tmp->latitude = atof(args);
+}
+
+void   wpt_lon(const char *args, const char **unused)
+{
+       wpt_tmp->longitude = atof(args);
+}
+
+ff_vecs_t yahoo_vecs = {
+        ff_type_file,
+       { ff_cap_read },
+        yahoo_rd_init,
+        yahoo_wr_init,
+        yahoo_rd_deinit,
+        NULL,
+        yahoo_read,
+        NULL,
+        NULL,
+        yahoo_args,
+       CET_CHARSET_ASCII, 0    /* CET-REVIEW */
+};